<template>
  <div class="toast">
    <div class="text">{{text}}成功</div>
  </div>
</template>

<script>
export default {
    props:["text"],
    mounted(){
        this.time = setTimeout(()=>{
           this.$emit("hideT")
        },2000)
    },
    beforeDestroy(){
        clearTimeout(this.time)
    }
};
</script>

<style>
.toast {
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.1);
  position: absolute;
  left: 0px;
  top: 0px;
}
.text {
  padding: 20px 40px;
  border: 1px solid #ccc;
  position: fixed;
  left:50%;
  top:50%;
  transform: translate(-50%,-50%);
  background: #fff;
}
</style>